<?php
	/*** By Weerachai Nukitram ***/
	/***  http://www.ThaiCreate.Com ***/

	$pd_id = trim($_POST["pro_id"]);

	$objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
	$objDB = mysql_select_db("db_stock");	

	$strSQL = "SELECT * FROM  tbl_products WHERE pd_code = '".$pd_id."' ";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	$objResult = mysql_fetch_array($objQuery);
	
	$pd_name=$objResult["pd_name"];
	$b_rate=$objResult["buying_price"];
	$s_rate=$objResult["selling_price"];
	if($objResult)
	{
		$sql="SELECT qty FROM tbl_stocks_available WHERE pd_name='$pd_name'";
		$result=mysql_query($sql);
		$row=mysql_fetch_assoc($result);
		$avail=$row['qty'];
		if($result){
			echo $pd_name."|".$b_rate."|".$s_rate."|".$avail;
		}else{
			echo "No Value"."|"."No Value"."|"."No Value"."|"."No Value";
		}
	}else{
		echo "No Value"."|"."No Value"."|"."No Value"."|"."No Value";
	}

	mysql_close($objConnect);
?>